using System.Collections;

namespace NUtil.maps {
    public class MapUtilities {
        public MapElement Element(object key, object value) {
            return new MapElement(key, value);
        }
        
        public IDictionary Map(params MapElement[] elements) {
            IDictionary map = new Hashtable();
            foreach (MapElement element in elements) {
                map.Add(element.Key, element.Value);
            }
            return map;
        }
        
        public void Merge(IDictionary mergeDestination, IDictionary mergeSource) {
            foreach (DictionaryEntry entry in mergeSource) {
                object destinationValue = mergeDestination[entry.Key];
                if (null != destinationValue) {
                    mergeDestination[entry.Key] = entry.Value;
                }
            }
        }
    }

    public class MapElement {
        private object key;
        private object value;

        public object Key
        {
            get { return key; }
        }

        public object Value {
            get { return value; }
        }

        public MapElement(object key, object value) {
            this.key = key;
            this.value = value;
        }
    }
}